package com.databaseManager;

/**
 * @author addzero
 * @version 1.0
 * 预编译sql语句
 * 命名使用C/C++宏定义风格
 * 需要后续传入的参数使用‘?’代替，参照样例格式
 */
public class SqlFunc {

	static final String SQL_INSERT_APPLY = "INSERT INTO table_apply VALUES (?,?,?)";
	static final String SQL_INSERT_DETAIL_APPLY = "INSERT INTO table_apply_checkment VALUES (?,?,?,?,?,?,?,?)";
	static final String SQL_INSERT_PRESCRIPTION = "INSERT INTO TABLE_APPLY_CHECKMENT VALUES (?,?,?,0)";
	static final String SQL_INSERT_DETAIL_PRESCRIPTION = "INSERT INTO TABLE_PRESCRIPTION_MEDICINE VALUES (?,?,'1',?,?)";
	static final String SQL_INSERT_RECORD = "INSERT INTO table_record VALUES (?,?,?,?,?,?,?,?,?,?);";
	static final String SQL_INSERT_PATIENT = "INSERT INTO table_patient VALUES (?,?,?,?,?,?,?,?);";
	static final String SQL_INSERT_DEP_REGISTER = "INSERT INTO table_dep_register VALUES (?,?,?);";
	static final String SQL_INSERT_PRO_REGISTER = "INSERT INTO table_pro_register VALUES (?,?,?);";
	static final String SQL_INSERT_DEP_PREREGISTER = "INSERT INTO table_dep_preregister VALUES (?,?,?,?);";
	static final String SQL_INSERT_PRO_PREREGISTER = "INSERT INTO table_pro_preregister VALUES (?,?,?,?);";
	static final String SQL_INSERT_DEP_QUEUENUMBER = "INSERT INTO table_dep_queuenumber VALUES (?,?,?,?,?);";
	static final String SQL_INSERT_PRO_QUEUENUMBER = "INSERT INTO table_pro_queuenumber VALUES (?,?,?,?,?);";

	static final String SQL_SELECT_PATIENT = "SELECT * FROM table_patient WHERE Pid = ?";
	static final String SQL_SELECT_DOCTOR = "SELECT * FROM table_employee WHERE Eid = ?";
	static final String SQL_SELECT_DEPARTMENT_BY_NAME = "SELECT DepNo FROM table_department WHERE DepName = ?";
	static final String SQL_SELECT_PROFESSOR = "SELECT * FROM table_employee NATURAL JOIN(table_room) " +
			"WHERE title = '专家' and DepNo = ?";
	static final String SQL_SELECT_DEPARTMENT_NAME_BY_DEPID = "SELECT DepName FROM table_department WHERE DepNo = ?";
	static final String SQL_SELECT_DEPARTMENT_BY_EID = "SELECT DepName\n" +
			"\tFROM table_employee NATURAL JOIN(table_room NATURAL JOIN(table_department))\n" +
			"\twhere Eid = ?";
	static final String SQL_SELECT_PREREGISTER_BY_PID = "SELECT * FROM table_dep_preregister WHERE Pid = ? UNION" +
			" SELECT * FROM table_pro_preregister WHERE Pid = ?";
	static final String SQL_SELECT_DEP_PREREGISTER = "SELECT * FROM TABLE_DEP_REGISTER WHERE Pid = ?";
	static final String SQL_SELECT_PRO_PREREGISTER = "SELECT * FROM TABLE_PRO_REGISTER WHERE Pid = ?";
	static final String SQL_SELECT_DEP_QUEUENUMBER = "SELECT * FROM table_dep_queuenumber WHERE Qid = ?";
	static final String SQL_SELECT_PRO_QUEUENUMBER = "SELECT * FROM table_pro_queuenumber WHERE Qid = ?";
	static final String SQL_SELECT_DEP_REGISTER = "SELECT * FROM table_dep_register WHERE Pid = ?";
	static final String SQL_SELECT_PRO_REGISTER = "SELECT * FROM table_pro_register WHERE Pid = ?";

	static final String SQL_SELECT_RECORDS = "SELECT * FROM table_patient WHERE Pid = ?";
	static final String SQL_SELECT_RECORD = "SELECT * FROM table_patient WHERE Pid = ? AND Rid = ?";

	static final String SQL_SELECT_MEDICINES = "SELECT MedId, MedName FROM TABLE_MEDICINE WHERE DIFFERENCE(?, MedName) < 3";
	static final String SQL_SELECT_MEDICINE = "SELECT Rid, Remain, Price FROM TABLE_MEDICINE WHERE Rid = ?";
	static final String SQL_SELECT_PRESCRIPTION = "SELECT Consum, Price FROM TABLE_PRESCRIPTION_MEDICINE NATURAL JOIN(TABLE_MEDICINE) WHERE Process = '4'";
	static final String SQL_SELECT_APPLY = "SELECT Price FROM TABLE_APPLY_CHECKMENT NATURAL JOIN(TABLE_CHECKMENT) WHERE Process = '4'";

	static final String SQL_UPDATE_RECORD = "UPDATE TABLE_RECORD SET UpdateTime = ?, "
																  + "InfectTime = ?, "
																  + "Treat = ?, "
																  + "DrugHistory = ?, "
																  + "MainComplaint = ?, "
																  + "CurMedicalHistory = ? WHERE Rid = ?";
	static final String SQL_UPDATE_PRESCRIPTION = "UPDATE table_prescription_medicine SET PROCESS = ?, "
			//+ "Payment = Consum * Price "
			+ "WHERE PrescribeId = ?";
	static final String SQL_UPDATE_APPLY = "UPDATE table_checkment SET Process = ?, "
			//+ "Payment = Price "
			+ "WHERE ApplyId = ?";

	/*static final String SQL_UPDATE_PRESCRIPTION = "UPDATE table_prescription_medicine, table_medicine SET PROCESS = ?, "
			//+ "Payment = Consum * Price "
			+ "WHERE PrescribeId = ? AND table_prescription_medicine.MedId = ?";
	static final String SQL_UPDATE_APPLY = "UPDATE table_apply_checkment, table_checkment SET Process = ?, "
			//+ "Payment = Price "
			+ "WHERE ApplyId = ? AND table_apply_checkment.CheckId = ?";*/
}

